Code
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
merged_data = pd.read_csv("data/merged_data.csv")“Kristin Lloyd”
merged_data['gun_law_strength'] = pd.Categorical(merged_data['gun_law_strength'],
categories=["national_failures", "weak_systems", "making_progress", "missing_key_laws", "national_leader"],
ordered=True
)
palette = {
"national_failures": "#ff0000",
"weak_systems": "#c61a09",
"making_progress": "#fab733",
"missing_key_laws": "#68bb59",
"national_leader": "#1c7416"
}
plt.figure(figsize=(10, 6))
sns.boxplot(
x="gun_law_strength",
y="firearm_mortality_by_state_2022",
data=merged_data,
order=["national_failures","weak_systems", "making_progress", "missing_key_laws", "national_leader"],
palette=palette
)
plt.xticks(rotation=25)
plt.xlabel("Gun Law Strength Category")
plt.ylabel("Firearm Mortality Rate (2022)")
plt.title("Firearm Mortality Rates by Gun Law Strength")
plt.grid(axis="y", linestyle="--", alpha=0.6)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3569590519.py:15: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
bins = [0, 10, 15, 20, 25, merged_data['firearm_mortality_by_state_2022'].max()]
labels = ["Very Low", "Low", "Moderate", "High", "Very High"]
merged_data['mortality_category'] = pd.cut(
merged_data['firearm_mortality_by_state_2022'], bins=bins, labels=labels
)
palette = {
"Very Low": "#1c7416",
"Low": "#68bb59",
"Moderate": "#fab733",
"High": "#ff0000",
"Very High": "#c61a09"
}
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='drug_overdose_mortality_rate',
palette=palette
)
plt.title("Drug Overdose Mortality Rate by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("Drug Overdose Mortality Rate (per 100,000)", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/309276589.py:17: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='state_ranking_in_mental_health_in_adults',
palette=palette,
width=0.6
)
plt.title("State Ranking in Mental Health in Adults by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("State Ranking in Mental Health (Lower is Better)", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3695444936.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='state_ranking_in_mental_health_in_youth',
palette=palette,
width=0.6
)
plt.title("State Ranking in Mental Health in Youth by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("State Ranking in Mental Health (Lower is Better)", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1953870607.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='access_to_mental_health_care_ranking',
palette=palette,
width=0.6
)
plt.title("State Ranking in Access to Mental Health by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("State Ranking in Mental Health (Lower is Better)", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3089964970.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='domestic_violence_shelters',
palette=palette,
width=0.6
)
plt.title("Number of Domestic Violence Shelters by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("Number of Domestic Violence Shelters", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1009034069.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='unemployment_rate',
palette=palette,
width=0.6
)
plt.title("Unemployment Rate by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("Unemployment Rate (%)", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3077409810.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='labor_participation_women_percentage',
palette=palette,
width=0.6
)
plt.title("Labor Participation of Women by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("Labor Participation of Women (%)", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1848554289.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='missing_person_by_state',
palette=palette,
width=0.6
)
plt.title("Number of Missing Persons by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("Number of Missing Persons", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/2717026357.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='gun_ownership_rates_per_state',
palette=palette,
width=0.6
)
plt.title("Gun Ownership Rates by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("Gun Ownership Rate (%)", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/286805501.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='suicide_by_firearms',
palette=palette,
width=0.6
)
plt.title("Suicides by Firearms by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("Number of Suicides by Firearms", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/2041839849.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='firearm_mortality_rate_children_one_to_nine_years_old',
palette=palette,
width=0.6
)
plt.title("Firearm Mortality Rate (Ages 1-9) by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("Firearm Mortality Rate (Ages 1-9) per 100,000", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1968679722.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='dv_people_to_shelter',
palette=palette,
width=0.6
)
plt.title("Domestic Violence Survivors per Shelter by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("DV Survivors per Shelter", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1367032867.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='dv_spending_per_person',
palette=palette,
width=0.6
)
plt.title("Domestic Violence Spending per Person by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("DV Spending per Person (USD)", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1300801361.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
['State', 'alcohol_related_death_rate', 'drug_overdose_mortality_rate', 'total_abortion_ban', 'abortion_protectiveness', 'access_to_mental_health_care_ranking', 'state_ranking_in_mental_health_in_youth', 'state_ranking_in_mental_health_in_adults', 'domestic_violence_shelters', 'dv_people_to_shelter', 'population', 'dv_spending_per_person', 'domestic_violence_spending_by_state', 'unemployment_rate', 'labor_participation_women_percentage', 'gun_law_strength', 'prohibition_for_stalkers', 'abusers_turn_in_gun_after_conviction', 'prohibition_for_domestic_abusers', 'prohibition_for_convicted_domestic_abusers', 'waiting_period', 'mental_health_in_background_check', 'funding_for_violence_intervention', 'no_purchase_after_violent_offense', 'age_requirement', 'mentaI_illness_prohibitor', 'hate_crime_prohibitor', 'gun_removal_program', 'fugitive_from_justice_prohibitor', 'felony_prohibitor', 'restraining_order_prohibitor', 'no_open_carry', 'no_guns_in_k_through_twelve_schools', 'no_guns_at_demonstrations', 'no_guns_on_college_campuses', 'bar_concealed_carry_by_people_with_violent_misdemeanors', 'high_capacity_magazines_prohibited', 'dealer_lisence_required', 'asault_weapons_prohibited', 'secure_storage_child_access_laws', 'rejected_shoot_first_laws', 'red_flag_laws', 'background_check_or_purchase_permit', 'concealed_carry_permit_required', 'extreme_risk_law', 'domestic_violence_percentage', 'num_schools', 'school_shootings', 'missing_person_by_state', 'gun_ownership_rates_per_state', 'suicide_by_firearms', 'firearm_mortality_by_state_2022', 'school_shootings_by_state_2024', 'firearm_mortality_rate_children_one_to_nine_years_old', 'mortality_category']
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='school_shootings',
palette=palette,
width=0.6
)
plt.title("School Shootings by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("School Shootings", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3711054348.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
Should do this by num of schools?
plt.figure(figsize=(10, 6))
sns.boxplot(
data=merged_data,
x='mortality_category',
y='alcohol_related_death_rate',
palette=palette,
width=0.6
)
plt.title("Alcohol Related Death Rate by Firearm Mortality Category", fontsize=14)
plt.xlabel("Firearm Mortality Category", fontsize=12)
plt.ylabel("Alcohol Related Death Rate", fontsize=12)
plt.xticks(rotation=45, fontsize=10)
plt.yticks(fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/557863687.py:2: FutureWarning:
Passing `palette` without assigning `hue` is deprecated and will be removed in v0.14.0. Assign the `x` variable to `hue` and set `legend=False` for the same effect.
Index(['State', 'alcohol_related_death_rate', 'drug_overdose_mortality_rate',
'total_abortion_ban', 'abortion_protectiveness',
'access_to_mental_health_care_ranking',
'state_ranking_in_mental_health_in_youth',
'state_ranking_in_mental_health_in_adults',
'domestic_violence_shelters', 'dv_people_to_shelter', 'population',
'dv_spending_per_person', 'domestic_violence_spending_by_state',
'unemployment_rate', 'labor_participation_women_percentage',
'gun_law_strength', 'prohibition_for_stalkers',
'abusers_turn_in_gun_after_conviction',
'prohibition_for_domestic_abusers',
'prohibition_for_convicted_domestic_abusers', 'waiting_period',
'mental_health_in_background_check',
'funding_for_violence_intervention',
'no_purchase_after_violent_offense', 'age_requirement',
'mentaI_illness_prohibitor', 'hate_crime_prohibitor',
'gun_removal_program', 'fugitive_from_justice_prohibitor',
'felony_prohibitor', 'restraining_order_prohibitor', 'no_open_carry',
'no_guns_in_k_through_twelve_schools', 'no_guns_at_demonstrations',
'no_guns_on_college_campuses',
'bar_concealed_carry_by_people_with_violent_misdemeanors',
'high_capacity_magazines_prohibited', 'dealer_lisence_required',
'asault_weapons_prohibited', 'secure_storage_child_access_laws',
'rejected_shoot_first_laws', 'red_flag_laws',
'background_check_or_purchase_permit',
'concealed_carry_permit_required', 'extreme_risk_law',
'domestic_violence_percentage', 'num_schools', 'school_shootings',
'missing_person_by_state', 'gun_ownership_rates_per_state',
'suicide_by_firearms', 'firearm_mortality_by_state_2022',
'school_shootings_by_state_2024',
'firearm_mortality_rate_children_one_to_nine_years_old',
'mortality_category'],
dtype='object')
import matplotlib.pyplot as plt
import seaborn as sns
palette = {
"Very Low": "#1c7416",
"Low": "#68bb59",
"Moderate": "#fab733",
"High": "#ff0000",
"Very High": "#c61a09"
}
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="prohibition_for_stalkers",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Prohibition for Stalkers Policy", fontsize=14)
plt.xlabel("Prohibition for Stalkers Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/822604134.py:27: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="abusers_turn_in_gun_after_conviction",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Gun Surrender Requirement for Abusers", fontsize=14)
plt.xlabel("Gun Surrender Policy for Convicted Abusers", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3867904504.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="prohibition_for_domestic_abusers",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Prohibition for Domestic Abusers", fontsize=14)
plt.xlabel("Prohibition for Domestic Abusers Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1927230965.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="prohibition_for_convicted_domestic_abusers",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Prohibition for Convicted Domestic Abusers", fontsize=14)
plt.xlabel("Prohibition for Convicted Domestic Abusers Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1936394731.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="waiting_period",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Waiting Period Policy", fontsize=14)
plt.xlabel("Waiting Period Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/177921753.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="mental_health_in_background_check",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Mental Health in Background Check Policy", fontsize=14)
plt.xlabel("Mental Health in Background Check Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1396511216.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="funding_for_violence_intervention",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Funding for Violence Intervention", fontsize=14)
plt.xlabel("Funding for Violence Intervention Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1954719845.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="no_purchase_after_violent_offense",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by No Purchase After Violent Offense Policy", fontsize=14)
plt.xlabel("No Purchase After Violent Offense Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/188156536.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="age_requirement",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Age Requirement Policy", fontsize=14)
plt.xlabel("Age Requirement Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3143884964.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="mentaI_illness_prohibitor",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Mental Illness Prohibitor Policy", fontsize=14)
plt.xlabel("Mental Illness Prohibitor Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/2152074464.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="hate_crime_prohibitor",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Hate Crime Prohibitor Policy", fontsize=14)
plt.xlabel("Hate Crime Prohibitor Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/2052316964.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="gun_removal_program",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Gun Removal Program Policy", fontsize=14)
plt.xlabel("Gun Removal Program Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/2969451868.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="fugitive_from_justice_prohibitor",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Fugitive from Justice Prohibitor Policy", fontsize=14)
plt.xlabel("Fugitive from Justice Prohibitor Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/2899254745.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
['State', 'alcohol_related_death_rate', 'drug_overdose_mortality_rate', 'total_abortion_ban', 'abortion_protectiveness', 'access_to_mental_health_care_ranking', 'state_ranking_in_mental_health_in_youth', 'state_ranking_in_mental_health_in_adults', 'domestic_violence_shelters', 'dv_people_to_shelter', 'population', 'dv_spending_per_person', 'domestic_violence_spending_by_state', 'unemployment_rate', 'labor_participation_women_percentage', 'gun_law_strength', 'prohibition_for_stalkers', 'abusers_turn_in_gun_after_conviction', 'prohibition_for_domestic_abusers', 'prohibition_for_convicted_domestic_abusers', 'waiting_period', 'mental_health_in_background_check', 'funding_for_violence_intervention', 'no_purchase_after_violent_offense', 'age_requirement', 'mentaI_illness_prohibitor', 'hate_crime_prohibitor', 'gun_removal_program', 'fugitive_from_justice_prohibitor', 'felony_prohibitor', 'restraining_order_prohibitor', 'no_open_carry', 'no_guns_in_k_through_twelve_schools', 'no_guns_at_demonstrations', 'no_guns_on_college_campuses', 'bar_concealed_carry_by_people_with_violent_misdemeanors', 'high_capacity_magazines_prohibited', 'dealer_lisence_required', 'asault_weapons_prohibited', 'secure_storage_child_access_laws', 'rejected_shoot_first_laws', 'red_flag_laws', 'background_check_or_purchase_permit', 'concealed_carry_permit_required', 'extreme_risk_law', 'domestic_violence_percentage', 'num_schools', 'school_shootings', 'missing_person_by_state', 'gun_ownership_rates_per_state', 'suicide_by_firearms', 'firearm_mortality_by_state_2022', 'school_shootings_by_state_2024', 'firearm_mortality_rate_children_one_to_nine_years_old', 'mortality_category']
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="felony_prohibitor",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Felony Prohibitor Policy", fontsize=14)
plt.xlabel("Felony Prohibitor Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1851041721.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="restraining_order_prohibitor",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Restraining Order Prohibitor Policy", fontsize=14)
plt.xlabel("Restraining Order Prohibitor Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3970029097.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="no_open_carry",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by No Open Carry Policy", fontsize=14)
plt.xlabel("No Open Carry Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1304131705.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="no_guns_in_k_through_twelve_schools",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by No Guns in K-12 Schools Policy", fontsize=14)
plt.xlabel("No Guns in K-12 Schools Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/940075044.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="no_guns_at_demonstrations",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by No Guns at Demonstrations Policy", fontsize=14)
plt.xlabel("No Guns at Demonstrations Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3799900291.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="no_guns_on_college_campuses",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by No Guns on College Campuses Policy", fontsize=14)
plt.xlabel("No Guns on College Campuses Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/2956535384.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="bar_concealed_carry_by_people_with_violent_misdemeanors",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Concealed Carry Ban for People with Violent Misdemeanors", fontsize=14)
plt.xlabel("Ban on Concealed Carry for People with Violent Misdemeanors", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3890029875.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="high_capacity_magazines_prohibited",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by High-Capacity Magazine Prohibition Policy", fontsize=14)
plt.xlabel("High-Capacity Magazines Prohibited Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3834443491.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="dealer_lisence_required",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Dealer License Requirement Policy", fontsize=14)
plt.xlabel("Dealer License Required Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3176922072.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="asault_weapons_prohibited",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Assault Weapons Prohibition Policy", fontsize=14)
plt.xlabel("Assault Weapons Prohibited Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/2651645352.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="secure_storage_child_access_laws",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Secure Storage & Child Access Laws", fontsize=14)
plt.xlabel("Secure Storage & Child Access Laws", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1664144617.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="rejected_shoot_first_laws",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Rejected Shoot First Laws", fontsize=14)
plt.xlabel("Rejected Shoot First Laws Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/1555323779.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="red_flag_laws",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Red Flag Laws", fontsize=14)
plt.xlabel("Red Flag Laws Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/697857874.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="background_check_or_purchase_permit",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Background Check or Purchase Permit Policy", fontsize=14)
plt.xlabel("Background Check or Purchase Permit Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3495000510.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="concealed_carry_permit_required",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Concealed Carry Permit Requirement Policy", fontsize=14)
plt.xlabel("Concealed Carry Permit Required Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/4097373513.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="extreme_risk_law",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Extreme Risk Law Policy", fontsize=14)
plt.xlabel("Extreme Risk Law Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3269229128.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.
plt.figure(figsize=(10, 6))
sns.histplot(
data=merged_data,
x="total_abortion_ban",
hue="mortality_category",
multiple="fill",
shrink=0.8,
palette=palette
)
plt.title("Firearm Mortality Rates by Total Abortion Ban Policy", fontsize=14)
plt.xlabel("Total Abortion Ban Policy", fontsize=12)
plt.ylabel("Proportion", fontsize=12)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.legend(title="Firearm Mortality Level", fontsize=10)
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.show()/var/folders/gf/ppk7yck96gx15bzg93b7fysm0000gn/T/ipykernel_42771/3599274300.py:16: UserWarning:
No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.